package com.example.mapper;

import com.example.entity.Room;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface RoomMapper {
    List<Room> selectAll(Room room);
    
    @Select("select r.*, h.name as hotelName from `room` r left join `hotel` h on r.hotel_id = h.id where r.id = #{id}")
    Room selectById(Long id);
    
    void insert(Room room);
    
    void updateById(Room room);
    
    @Delete("delete from `room` where id = #{id}")
    void deleteById(Long id);
    
    List<Room> selectByHotelId(Long hotelId);

    // 新增预订房间方法
    @Update("update `room` set status = 1 where id = #{roomId} and status = 0")
    int bookRoom(Long roomId);

}